#if _MSC_VER>1000
#pragma once
#endif

#include "ImageFilter.h"

class AuSample
{

public:
	virtual int open(int,int,int)=0;
	virtual int write(BYTE *,int,int,int,int)=0;
	virtual void close()=0;
	virtual void flush()=0;

};

class ImageSample
{

public:
	virtual void Init()=0;
	virtual void Process(RGBTRIPLE *prgb,int cxImage,int cyImage)=0;
	virtual void Configure(HWND hwnd)=0;
	virtual void Quit()=0;
};

typedef  ImageSample* (*INIT)();

DECLARE_INTERFACE_(IAuFilter,IUnknown)
{
	STDMETHOD(SetDspfunction)(THIS_ AuSample*)PURE;
	STDMETHOD(SetStop)(THIS_)PURE;
};

DECLARE_INTERFACE_(IFilterInterface,IUnknown)
{

	STDMETHOD (SetOptions)(THIS_ int topt)PURE;
	STDMETHOD (SelectConfigure)(THIS_)PURE;
	STDMETHOD (SetSmooth)(THIS_ int topts)PURE;
	STDMETHOD (SetExtEff)(THIS_ int teopt)PURE;
	STDMETHOD (SetExtEff)(THIS_ char*fname)PURE;
	STDMETHOD (SetConfigure)(THIS_ HWND hwnd)PURE;
	STDMETHOD (SetStop)(THIS_)PURE;

};

class AuFilter:public CTransInPlaceFilter,public IAuFilter
{
public:
	DECLARE_IUNKNOWN;

	static CUnknown* WINAPI CreateInstance(LPUNKNOWN,HRESULT*);
	STDMETHODIMP NonDelegatingQueryInterface(REFIID riid,void ** ppv);
	HRESULT Transform(IMediaSample *pSample);
		
	HRESULT CheckInputType(const CMediaType*pmtin);
	
	STDMETHODIMP SetDspfunction(AuSample*);
	STDMETHODIMP SetStop();

public:
	AuSample*mod;
private:
	AuFilter(TCHAR*,LPUNKNOWN,HRESULT*);
	//CCritSec            m_GargleLock;
	WAVEFORMATEX wf;
};

class Filter:public CTransInPlaceFilter,
			 public IFilterInterface
			
{

public:

	DECLARE_IUNKNOWN;
	static CUnknown* WINAPI CreateInstance(LPUNKNOWN,HRESULT*);
    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void ** ppv);
	HRESULT Transform(IMediaSample*pSample);
	HRESULT CheckInputType(const CMediaType*pmtin);

	STDMETHODIMP SetOptions(int topt);
	STDMETHODIMP SetSmooth(int topts);
	STDMETHOD(SetExtEff)(int teopt);
	STDMETHOD(SetExtEff)(char *fname);
	STDMETHODIMP SetConfigure(HWND);
	STDMETHODIMP SetStop();
	STDMETHODIMP SelectConfigure();	
private:

	Filter(TCHAR*,LPUNKNOWN,HRESULT*);
	~Filter();

	ImageSample *img;
	INIT Init;
	HMODULE hmod;
	int iOptionSmooth;
	int iOption;
	int iExtEff;
	int cxImage,cyImage;

	CImageFilter m_filter;


};

AuSample* GetData();
